﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SPMS.Commons.Configuration
{
    /// <summary>
    /// 配置属性错误异常
    /// </summary>
    /// <remarks>用于包装与配置属性相关的错误信息</remarks>
    /// <history>
    /// [zanezeng]   2008-11-18 13:51    Created
    /// </history>
    [Serializable]
    public class ConfigurationAttributeException : ConfigurationException
    {
        #region ---Constructor

        /// <summary>
        /// 指定错误消息和对作为此异常原因的内部异常的引用来初始化初始化 <see cref="ConfigurationAttributeException"/>新实例
        /// </summary>
        /// <param name="message">错误提示信息</param>
        /// <param name="node">发生错误的配置节点</param>
        /// <param name="attributeName">发生错误的属性名称</param>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]   2008-10-14 5:00 PM    Created
        /// </history>
        public ConfigurationAttributeException(string message, IConfigurationNode node, string attributeName)
            : this(message, null, node, attributeName)
        {
        }

        /// <summary>
        /// 指定错误消息和对作为此异常原因的内部异常的引用来初始化初始化 <see cref="ConfigurationAttributeException"/>新实例
        /// </summary>
        /// <param name="message">错误提示信息</param>
        /// <param name="innerException">内部异常</param>
        /// <param name="node">发生错误的配置节点</param>
        /// <param name="attributeName">发生错误的属性名称</param>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]   2008-10-14 5:00 PM    Created
        /// </history>
        public ConfigurationAttributeException(string message, Exception innerException, IConfigurationNode node, string attributeName)
            : base(message, innerException, node)
        {
            //保存参数
            this.m_AttributeName = attributeName;
        }

        #endregion

        #region ---Property

        /// <summary>
        /// 获得发生错误的属性名称
        /// </summary>
        /// <value>发生错误的属性名称</value>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]   2008-11-7 14:15    Created
        /// </history>
        public string AttributeName
        {
            get
            {
                return this.m_AttributeName;
            }
        }

        #endregion

        #region ---Field

        /// <summary>
        /// 发生错误的属性名称
        /// </summary>
        private string m_AttributeName;

        #endregion
    }
}
